import { CONFIG } from "@/constants";
import { UploadFile } from "antd";
import dayjs from "dayjs";

export const normCity = (e: any, options) => {
    return options.map((item) => {
        return {
            label: item.label,
            value: item.value,
        };
    });
};
export const normCityGetVal = (e: any) => {
    if (e) {
        return { value: e.map((item) => item.value) };
    }
};
export const normFileGetVal = (e: any) => {
    if (e) {
        return e.map((item) => {
            return {
                url: CONFIG.IMAGE_URL + item.url
            }
        });
    }
};
export const normFile = (e: any): UploadFile<any> | Array<UploadFile<any>> => {
    if (e.file?.status === 'done') {
        return e.fileList.map((f:UploadFile) => {
            return {
                url: f.response.data.url,
            };
        });
    }
    return e?.fileList;
};
export const normDateGetVal = (e: any) => {
    if (e) {
        return dayjs(e, 'YYYY-MM-DD');
    }
};